<template>
  <div>
    <el-tabs>
      <el-tab-pane label="登录账户设置" name="first">

        <el-form ref="addForm" :model="detailList" class="position" label-width="100px">
          <el-form-item label="姓名" style="width:50%"><el-input v-model="detailList.username" /></el-form-item>
          <el-form-item label="密码" style="width:50%"><el-input v-model="detailList.password" /></el-form-item>

          <el-form-item>
            <el-button type="primary" @click="isOk">确定</el-button>
            <el-button>取消</el-button>
          </el-form-item>

        </el-form>

      </el-tab-pane>
      <el-tab-pane label="个人详情" name="second">
        <userin />
      </el-tab-pane>
      <el-tab-pane label="岗位信息" name="third">
        <job />
      </el-tab-pane>
    </el-tabs>
    <!-- 测试用 -->

  </div>
</template>

<script>
import { getUserDetailById, saveUserDetailById } from '@/api/employees'
import userin from './components/userin.vue'
import job from './components/job.vue'
export default {
  components: {
    userin,
    job
  },

  data() {
    return {
      detailList: {},
      id: this.$route.params.id

    }
  },
  created() {
    console.log(this.$route.params)
    this.getUserDetailById()
  },
  methods: {
    async getUserDetailById() {
      this.detailList = { ...await getUserDetailById(this.id), password: '' }
    },
    async isOk() {
      await this.$refs.addForm.validate()
      await saveUserDetailById(this.detailList)
      this.$message.success('保存用户信息成功')
    }
  }

}
</script>

<style scoped>
 .position{
margin-top:100px;
margin-left:100px;

 }
</style>
